#ifndef __COUNT_DOWN_LATCH_H__
#define __COUNT_DOWN_LATCH_H__

#include <boost/utility.hpp>
#include "mutex_lock.h"
#include "condition.h"

namespace mars {

class CountDownLatch : boost::noncopyable {
    public:
        explicit CountDownLatch(int count);
        /*
         * @brief wait if count > 0
         */
        void wait();
        void count_down();
        int get_count();

    private:
        int _count;
        MutexLock _mutex;
        Condition _cond;
};

} // namespace mars

#endif // __COUNT_DOWN_LATCH_H__
